package pers.chy.chyappointmentplatform.Service;


import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import pers.chy.chyappointmentplatform.WS.WsClient_HIP;


/**
 * 门诊公告屏服务类（诊显）
 */
@Service
public class ClinicBulletinBoardService {


    /**
     * 异步调用：诊显
     */
    @Async
    public void doShow(
                        String 科室名称,
                        String 诊室名称,
                        String 医生编号,
                        String 医生名称,
                        String 医生职称,
                        String 医生简介,
                        String 正在就诊患者名称,
                        String 正在就诊患者编号,
                       String 等候患者名称,
                       String 等候患者编号,
                       String 绑定计算机名)
            throws Exception {
        String param=
                "<BSXml>" +
                "<MsgHeader>" +
                        "<Sender>CAP</Sender>" +
                        "<MsgType>CBB_0101</MsgType>" +
                        "<MsgVersion>3.0</MsgVersion>" +
                "</MsgHeader>" +
                "<PatientInfo>" +
                        "<DeptName>科室名称</DeptName>" +
                        "<ClinicName>诊室名称</ClinicName>" +
                        "<DoctorID>医生编号</DoctorID>" +
                        "<DoctorName>医生名称</DoctorName>" +
                        "<DoctorTitle>医生职称</DoctorTitle>" +
                        "<DoctorDesc>医生简介</DoctorDesc>" +
                        "<PatientName>正在就诊患者名称-正在就诊患者编号</PatientName>" +
                        "<PatientWaitName>等候患者名称-等候患者编号</PatientWaitName>" +
                        "<PatientPass></PatientPass>" +                      // 过号患者名称-过号患者编号
                        "<IPaddress>绑定计算机名</IPaddress>" +                // 显示屏所在诊室的绑定计算机名
                "</PatientInfo>" +
                "</BSXml>";

        try {
            param =param.replace("科室名称",科室名称)
                        .replace("诊室名称",诊室名称)
                        .replace("医生编号",医生编号)
                        .replace("医生名称",医生名称)
                        .replace("医生职称",医生职称)
                        .replace("医生简介",医生简介)
                        .replace("正在就诊患者名称",正在就诊患者名称)
                        .replace("正在就诊患者编号",正在就诊患者编号)
                        .replace("等候患者名称",等候患者名称)
                        .replace("等候患者编号",等候患者编号)
                        .replace("绑定计算机名",绑定计算机名);

//            String res = WsClient_HIP.call("ClinicBulletinBoard","","",param);
//            System.out.println("诊显WS返回="+res);

            WsClient_HIP.call("ClinicBulletinBoard","","",param);
            WsClient_HIP.call("ClinicBulletinBoard","","",param);

        } catch (Exception e) {
            // 其实在@Async异步方法中抓不到异常
            throw e;
        }
    }
}
